unit uAppInstanceCursor;

interface
uses
  uAppInstanceInterfaces;

type

  TAppInstanceCursor = class(TInterfacedObject, ICursor)
  private
    FCount : integer;
    procedure BeginWait;
    procedure EndWait;
    procedure ResetWait;
  public
    procedure AfterConstruction; override;
  end;

implementation

uses
  Forms, Controls;

{TAppInstanceCursor}
procedure TAppInstanceCursor.AfterConstruction;
begin
  inherited;
  FCount := 0;
end;

procedure TAppInstanceCursor.BeginWait;
begin
  if FCount = 0 then
    Screen.Cursor := crHourGlass;
  Inc(FCount);
end;

procedure TAppInstanceCursor.EndWait;
begin
  if FCount > 0 then
    Dec(FCount);
  if FCount = 0 then
    Screen.Cursor := crDefault;
end;

procedure TAppInstanceCursor.ResetWait;
begin
  FCount := 0;
  Screen.Cursor := crDefault;
end;

end.
 